//战役时间引擎
//用法：生成新的时间，转换当前势力到下一势力

var campaignTimeEngine = {

	TurnForce : function(time_ref, forceCount){
		time_ref.force_of_step = (time_ref.force_of_step + 1) % forceCount;
	},
	
	BuildNewTime : function(time_ref){
		var calender = this._BuildCalender(time_ref.time, time_ref.time_of_step);

		time_ref.current_step++;
		time_ref.time[2] += time_ref.time_of_step;
		if (time_ref.time[2] > calender[time_ref.time[1]]){
			time_ref.time[2] -= calender[time_ref.time[1]];
			time_ref.time[1]++;
		}
		if (time_ref.time[1] > 12){
			time_ref.time[1] -= 12;
			time_ref.time[0]++;
		}
	},
		
	_BuildCalender : function(date,ticktime){
		var calender = [0,31,28,31,30,31,30,31,31,30,31,30,31];
		if (ticktime < 1){
			if (date[1] != 2 || date[2] < 28){
				return calender;
			}
		}else if (ticktime < 28){
			if (date[1] != 2){
				return calender;
			}
		}
		//maybe cross 2.29
		if (date[0] % 100 == 0){
			if (date[0] % 400 == 0){
				calender[2] = 29;
			}
		}else{
			if (date[0] % 4 == 0){
				calender[2] = 29;
			}
		}
		return calender;
	},
};